//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.eResearch.Publisher.Wcf
{
    using System.ServiceModel;
    using Microsoft.Research.eResearch.Blackboard.Common;

    /// <summary>
    /// Provides the service implementation for the <see cref="IWcfPublisherSubscriptionService"/> interface.
    /// </summary>
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class WcfPublisherSubscriptionService : IWcfPublisherSubscriptionService
    {
        /// <summary>
        /// Allows the blackboard to instruct the publisher to use a new subscription profile.
        /// </summary>
        /// <param name="profile">The new subscription profile.</param>
        public void UpdateSubscriptionProfile(SubscriptionProfile profile)
        {
            PublisherSubscriptionReceiverExtension ext = OperationContext.Current.Host.Extensions.Find<PublisherSubscriptionReceiverExtension>();
            ext.Subscribe(profile);
        }
    }
}
